package GameLogic

import (
	"git.oschina.net/yangdao/GameLib/Unit"
	"git.oschina.net/yangdao/SGLisp"
	"git.oschina.net/yangdao/SGLisp/parse"
)

type EffectUnitState struct {
	*Unit.Effect
	state string
}

func createEfffectUnitState(args []parse.Node, context *SGLisp.Context) Unit.IEffect {
	retUnitState := &EffectUnitState{
		Effect: &Unit.Effect{},
	}
	args = SGLisp.EvalArgs(args, context)
	retUnitState.state = SGLisp.EvalNode(args[1], context).(string)
	return retUnitState
}

func (this *EffectUnitState) OnExec(context *SGLisp.Context) {
	//if this.DstUnit.Base().IsDie == false {
	if this.state == "hitFly" {
		this.DstUnit.(*GameUnit).chageState(this.state, this.SrcUnit.Base().Dir)
	} else {
		this.DstUnit.(*GameUnit).chageState(this.state)
	}
	//}
}
